package com.eduhzy.ttw.teacher.di.module;

import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.eduhzy.ttw.commonsdk.entity.ChooseClassData;
import com.eduhzy.ttw.commonsdk.holder.AutoBaseViewHolder;
import com.eduhzy.ttw.teacher.R;
import com.eduhzy.ttw.teacher.mvp.contract.CreateClassContract;
import com.eduhzy.ttw.teacher.mvp.model.CreateClassModel;
import com.jess.arms.di.scope.ActivityScope;

import java.util.ArrayList;
import java.util.List;

import dagger.Binds;
import dagger.Module;
import dagger.Provides;


@Module
public abstract class CreateClassModule {

    @Binds
    abstract CreateClassContract.Model bindCreateClassModel(CreateClassModel model);
    @ActivityScope
    @Provides
    static List<ChooseClassData> provideCreateClassList() {
        return new ArrayList<>();
    }

    @ActivityScope
    @Provides
    static BaseQuickAdapter<ChooseClassData, AutoBaseViewHolder> provideCreateClassAdapter(List<ChooseClassData> list) {
        return new BaseQuickAdapter<ChooseClassData, AutoBaseViewHolder>(R.layout.rv_item_choose_class, list) {
            @Override
            protected void convert(AutoBaseViewHolder helper, ChooseClassData item) {
                helper.setText(R.id.class_name, item.getName());
                helper.getView(R.id.class_selected_btn).setSelected(item.isSelected());
            }
        };
    }

    @ActivityScope
    @Provides
    static RecyclerView.LayoutManager provideCreateClassLayoutManger(CreateClassContract.View view) {
        return new LinearLayoutManager(view.getActivity());
    }


}